package com.javabasic.algorithm.leetcode;

public class PalindromeNumber {

    public boolean isPalindrome(int x) {
        if (x < 0) return false;
        int arr[] = new int[20];
        int len = 0;
        while (x > 0) {
            arr[len++] = x%10;
            x /= 10;
        }
        for (int i = 0; i < len/2; i++) {
            if (arr[i] != arr[len-1-i]) return false;
        }
        return true;
    }
    public boolean isPalindrome2(int x) {
        if (x < 0) return false;
        int src = x;
        long temp = 0;
        while (x > 0) {
            temp = temp*10 + x%10;
            x /= 10;
        }
        return temp == src;
    }
}
